/**
* @author AlbertDarren
* @contact 2563491540@qq.com
*/
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <vector>
using namespace std;
void printVector(int element)
{
    cout << element << " ";
}
template<typename Tp>
class Multiply
{
private:
    Tp init_value;
    Tp cnt=0;
public:
    Multiply(Tp init_value)
    {
        this->init_value=init_value;
    }
    void operator()(Tp &ele)
    {
        ++cnt;
        ele*=init_value;
    }
    Tp getCnt()
    {
        return cnt;
    }
};
int main_34()
{
    srand((unsigned int)time(nullptr));
    vector<int> int_vect;
    int random_int;
    for (int i=0; i<20 ; ++i )
    {
        random_int=rand()%20;
        int_vect.push_back(random_int);
    }
    for_each(int_vect.begin(),int_vect.end(),printVector);
    cout << endl;
    random_int=rand()%20;
    Multiply<int> mu=for_each(int_vect.begin(),int_vect.end(),Multiply<int>(random_int));
    cout << "Multiply every element by "<<random_int << endl;
    for_each(int_vect.begin(),int_vect.end(),printVector);
    cout << endl;
    cout << "The size of container is "<<mu.getCnt() << endl;
    return 0;
}
